<template>
  <div>
    <el-cascader
      :props="checkstrictly"
      @change="change"
      filterable
      style="width: 100%"
      v-model="optiondata"
      :options="addressOptions"
    ></el-cascader>
  </div>
</template>
<script>
import { getSSQ } from "@/api/user";
import axios from "axios";
export default {
  name: "CasCader",
  data() {
    return {
      optiondata: this.treeoption,
      addressOptions: [],
    };
  },
  methods: {
    init() {
      // var url;
      // if (this.type == 1) {
      //   url = "assets/libs/shengshiqu/city-data-level3.json";
      // } else if (this.type == 2) {
      //   url = "assets/libs/shengshiqu/city-data-level2.json";
      // } else if (this.type == 3) {
      //   url = "assets/libs/shengshiqu/city-data-level1.json";
      // }
      // // const res = await getSSQ(url)
      // // console.log(res);
      // // axios.get('../assets/shengshiqu')
      // axios.get(url).then(res=>{
      //   console.log(res);
      // })
    },
    change(val) {
      this.$emit("update:treeoption", val);
    },
  },
  props: {
    type: {
      type: Number,
    },
    treeoption: {
      // type: Array
    },
    checkstrictly: {
      type: Object,
    },
    is_clear: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    is_clear(val) {
      if (val) {
        this.addressOptions = [];
      }
    },
  },
  mounted() {
    this.init();
  },
};
</script>
